package com.hfjava.practice02;

import java.util.Scanner;

/**
 * @author Administrator
 * @version V1.0
 * @ProjectName:IntelliJ IDEA
 * @PackageName: com.hfjava.practice01.practice02
 * @ClassName: JudgeTimes
 * @Description: TODO(这里用一句话描述这个类的作用)
 * @date 2019/12/19 17:24
 * @Copyright 大牛版板所有
 */
public class JudgeTimes {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.print("请输入一段字符串：");
        String str = input.next();
        System.out.print("请输入你要查找的字符：");
        String lookupStr = input.next();
        int count = 0;
        for (int i = 0; i < str.length()-lookupStr.length(); i++) {
            if (lookupStr.equals(str.substring(i,i+lookupStr.length()))){
                count++;
            }
        }
        if (count == 0){
            System.out.println("你要查找的字符不存在！");
        }
        else {
            System.out.println(str+"中出现"+count+"个"+lookupStr);
        }
    }
}
